package jbase.project.system.spark;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.InitBinder;

@Component
public class Spark {

	static JavaSparkContext sc;

	@InitBinder
	public void init() {
		SparkConf conf = new SparkConf();
		conf.setAppName("jbase");
		conf.setMaster("spark://spark.master:7077");
		sc = new JavaSparkContext(conf);
	}

	public JavaSparkContext getSparkContext() {
		if (sc == null) {
			init();
		}
		return sc;
	}

}
